@extends('wap.layouts.master')
@section('title')
	@if ($_GET['team_id'])
		资料编辑
	@elseif (!$_GET['team_id'])
		创建球队
	@endif
@endsection

@section('content')

<div class="aw-main aw-user aw-user-info" id="Form-team_edit">
	<!--表单-开始-->
	<ul class="aw-assest-form aw-bg-fff aw-mt15">
		<li class="aw-form-li aw-user-info-img">
			<div class="aw-left">队徽</div>
			<div class="aw-conter aw-pr20">
				<img :src="form.img ? form.img : '/wap/img/login_img.png'" onerror="javascript:this.src='/wap/img/login_img.png';">
				<input type="file" name="upfile" id="file_img" v-on:click="Click_UpImg('img')">
				<input type="text" id="img" v-model="form.img" :value="form.img" class="aw-hide" placeholder="请上传队徽">
			</div>
			<div class="aw-icon aw-icon-more aw-right"></div>
		</li>
	</ul>
	<ul class="aw-assest-form aw-bg-fff aw-mt10">
		<li class="aw-form-li">
			<div class="aw-left">球队名称</div>
			<div class="aw-conter">
				<input type="text" placeholder="请输入球队名称" id="name" name="name" v-model="form.name" :value="form.name">
			</div>
		</li>
		<li class="aw-form-li">
			<div class="aw-left">成立时间</div>
			<div class="aw-conter aw-pr20">
				<input type="text" placeholder="请选择成立时间" id="create_time" name="create_time" v-model="form.create_time" :value="form.create_time" readonly="readonly">
			</div>
			<div class="aw-icon aw-icon-more aw-right"></div>
		</li>
		<li class="aw-form-li">
			<div class="aw-left">平均年龄</div>
			<div class="aw-conter">
				<input type="text" placeholder="请输入平均年龄" id="avg_age" name="avg_age" v-model="form.avg_age" :value="form.avg_age">
			</div>
		</li>
		<li class="aw-form-li">
			<div class="aw-left">球队主色</div>
			<div class="aw-conter">
				<input type="text" placeholder="请输入球队主色" id="colour" name="colour" v-model="form.colour" :value="form.colour">
			</div>
		</li>
	</ul>
	<ul class="aw-assest-form aw-bg-fff aw-mt10">
		<li class="aw-form-li aw-textarea">
			<div class="aw-left">球队介绍</div>
			<div class="aw-conter">
				<textarea placeholder="请输入球队介绍" id="desc" name="desc" v-model="form.desc" :value="form.desc"></textarea>
			</div>
		</li>
	</ul>
	<!--表单-结束-->
</div>
<div class="aw-bg-fff aw-foot-btn aw-foot-btn2">
	<a href="javascript:;" v-on:click="Save_Team" class="aw-assest-btn aw-btn-bgcolor-lvse">
		@if ($_GET['team_id'])
			保存
		@elseif (!$_GET['team_id'])
			立即创建
		@endif
	</a>
</div>

@section('pagejs')
@parent
<!--手机端日期插件-->
<link href="/wap/js/mobiscroll/mobiscroll.css" rel="stylesheet" type="text/css">
<link href="/wap/js/mobiscroll/mobiscroll_color.css" rel="stylesheet" type="text/css">
<link href="/wap/js/mobiscroll/mobiscroll_android.css" rel="stylesheet" type="text/css">
<script src="/wap/js/mobiscroll/mobiscroll_base.js" type="text/javascript"></script>
<script src="/wap/js/mobiscroll/mobiscroll_cn.js" type="text/javascript"></script>
<script src="/wap/js/mobiscroll/mobiscroll.js" type="text/javascript"></script>

<!--图片上传-->
<script type="text/javascript" src="/library/jquery-file-upload/js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="/library/jquery-file-upload/js/jquery.fileupload.js"></script>
<style>
.dwbc-p .dwbw{width: 33.33%;}
.android-ics .dw .dwb-a{background:#1BC96C !important;}
</style>
<script type="text/javascript">
var MJS_URLArry=URLArry;
MJS_URLArry.id=MJS_URLArry.team_id;
var Vue_Data={
	form:{img:'',name:'',create_time:'',avg_age:'',colour:'',desc:'',},
}
if(MJS_URLArry.team_id>0){
	var AD_info={
		api:'/api/team/team-info',
		form_data:{team_id:MJS_URLArry.team_id},
		tips:false,
	}
	getData(AD_info,function(ajax_data){
		var info_team={
			id:ajax_data.id,
			img:ajax_data.img,
			name:ajax_data.name,
			create_time:ajax_data.create_time,
			avg_age:ajax_data.avg_age,
			colour:ajax_data.colour,
			desc:ajax_data.desc,
		}
		$.extend(Vue_Data.form,info_team);
	})
}
$(document).on('click','#time',function(){
	$(this).blur()
})
vm=new Vue({
	el:'#Vue-body',
	data:Vue_Data,
	methods:{
		Click_UpImg:function(name){
			Img_Upload(name,function(This,name,url){
				vm.form.img=url;
			})
		},Save_Team:function(){
			Form_Verification('#Vue-body',vm.form,'desc',function(ver_code){
				if(ver_code==1){
					var AD_info_edit={
						api:'/api/team/create-team',
						form_data:vm.form,
						tips:'@if($_GET['team_id'])编辑球队信息@elseif(!$_GET['team_id'])创建球队@endif成功',
					}
					console.log('--------------AD_info_edit')
					console.log(AD_info_edit)
					postData(AD_info_edit,function(){
						//获取用户详情存进缓存
						Get_User_Info('','/wap/team/my')
					})
				}
			})
		}
	}
})
$(function(){
	var currYear = (new Date()).getFullYear();	
	var opt={};
	opt.date = {preset : 'date'};
	opt.datetime = {preset : 'datetime'};
	opt.time = {preset : 'time'};
	opt.default = {
		theme: 'android-ics light', //皮肤样式
	    display: 'modal', //显示方式 
		mode: 'scroller', //日期选择模式
		dateFormat: 'yyyy-mm-dd',
		lang: 'zh',
		showNow: true,
		nowText: "今天",
        startYear: currYear - 50, //开始年份
        endYear: currYear, //结束年份
        onSelect:function(valueText,inst){
	  		vm.form.create_time = valueText;
	  	}
	};
  	$("#create_time").mobiscroll($.extend(opt['date'], opt['default']));
});
</script>
@endsection

@endsection

